package com.jsh.erp.remote;

import com.jsh.erp.datasource.entities.DepotHead;
import com.jsh.erp.service.depotHead.DepotHeadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("/remote/api/depotHead")
public class DepotHeadApi {
    @Autowired
    private DepotHeadService depotHeadService;

    // 单个账户的金额求和-入库和出库
    @GetMapping("/getAccountSum")
    public BigDecimal getAccountSum(@RequestParam("id") Long id,
                                    @RequestParam("timeStr") String timeStr,
                                    @RequestParam("type") String type) throws Exception {
        return depotHeadService.getAccountSum(id, timeStr, type);
    }

    // 单个账户的金额求和-多账户的明细合计
    @GetMapping("/getManyAccountSum")
    public BigDecimal getManyAccountSum(@RequestParam("id") Long id,
                                        @RequestParam("timeStr") String timeStr,
                                        @RequestParam("type") String type) throws Exception {
        return depotHeadService.getManyAccountSum(id, timeStr, type);
    }

    // 校验单据主表
    @GetMapping("/getDepotHeadListByAccountIds")
    public List<DepotHead> getDepotHeadListByAccountIds(@RequestParam("accountIds") String[] accountIds) {
        return depotHeadService.getDepotHeadListByAccountIds(accountIds);
    }

    @GetMapping("/getDepotHead")
    public DepotHead getDepotHead(@RequestParam("number") String number) throws Exception {
        return depotHeadService.getDepotHead(number);
    }
}
